/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.comfacauca.xmlc2.entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author eorozco
 */
@Entity
@Table(name = "iteracion")
@NamedQueries({
    @NamedQuery(name = "Iteracion.findAll", query = "SELECT i FROM Iteracion i"),
    @NamedQuery(name = "Iteracion.findById", query = "SELECT i FROM Iteracion i WHERE i.id = :id"),
    @NamedQuery(name = "Iteracion.findByCodigo", query = "SELECT i FROM Iteracion i WHERE i.codigo = :codigo"),
    @NamedQuery(name = "Iteracion.findByDescripcion", query = "SELECT i FROM Iteracion i WHERE i.descripcion = :descripcion"),
    @NamedQuery(name = "Iteracion.findByInicio", query = "SELECT i FROM Iteracion i WHERE i.inicio = :inicio"),
    @NamedQuery(name = "Iteracion.findByFin", query = "SELECT i FROM Iteracion i WHERE i.fin = :fin")})
public class Iteracion implements Serializable {
    @OneToMany(mappedBy = "idIteracion")
    private Collection<Requerimiento> requerimientoCollection;
    private static final long serialVersionUID = 1L;
    @Id
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "codigo")
    private String codigo;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 300)
    @Column(name = "descripcion")
    private String descripcion;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "inicio")
    @Temporal(TemporalType.DATE)
    private Date inicio;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "fin")
    @Temporal(TemporalType.DATE)
    private Date fin;
    
    @JoinColumn(name = "id_proyecto", referencedColumnName = "id")    
    @ManyToOne(optional = false)
    private Proyecto idProyecto;
    
    @JoinColumn(name = "id_responsable", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Responsable idResponsable;

    public Iteracion() {
    }

    public Iteracion(Integer id) {
        this.id = id;
    }

    public Iteracion(Integer id, String codigo, String descripcion, Date inicio, Date fin) {
        this.id = id;
        this.codigo = codigo;
        this.descripcion = descripcion;
        this.inicio = inicio;
        this.fin = fin;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Date getInicio() {
        return inicio;
    }

    public void setInicio(Date inicio) {
        this.inicio = inicio;
    }

    public Date getFin() {
        return fin;
    }

    public void setFin(Date fin) {
        this.fin = fin;
    }

    public Proyecto getIdProyecto() {
        return idProyecto;
    }

    public void setIdProyecto(Proyecto idProyecto) {
        this.idProyecto = idProyecto;
    }

    public Responsable getIdResponsable() {
        return idResponsable;
    }

    public void setIdResponsable(Responsable idResponsable) {
        this.idResponsable = idResponsable;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Iteracion)) {
            return false;
        }
        Iteracion other = (Iteracion) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.comfacauca.xmlc2.entidades.Iteracion[ id=" + id + " ]";
    }

    public Collection<Requerimiento> getRequerimientoCollection() {
        return requerimientoCollection;
    }

    public void setRequerimientoCollection(Collection<Requerimiento> requerimientoCollection) {
        this.requerimientoCollection = requerimientoCollection;
    }
    
}
